﻿<%@  Title="" Language="C#" MasterPageFile="~/Admin/ContentFrame.master" AutoEventWireup="true" CodeBehind="Feedbacks.aspx.cs"
    Inherits="ETD.WebManagement.Admin.FeedbackManage.Feedbacks" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxLoadingPanel ID="loadingPanel" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManagerDefault">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="searchPanel" />
                    <telerik:AjaxUpdatedControl ControlID="rgFeedbacks" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnMoreActionRun">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="searchPanel" />
                    <telerik:AjaxUpdatedControl ControlID="rgFeedbacks" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="rgFeedbacks">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgFeedbacks" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>

        </AjaxSettings>
    </telerik:RadAjaxManager>

    <asp:Panel ID="searchPanel" runat="server">
        <telerik:RadDockLayout ID="SearchRadDockLayout" runat="server">
            <telerik:RadDockZone ID="SearchRadDockZone" runat="server" Orientation="Vertical" BorderWidth="0"
                Resizable="true">
                <telerik:RadDock ID="SearchRadDock" runat="server" Title="搜索：" EnableDrag="false"
                    DockHandle="TitleBar" DockMode="Docked" EnableAnimation="true" EnableRoundedCorners="false">
                    <ContentTemplate>
                        <div class="searchPanel">
                            <div>
                                <label>名称：</label>
                                <telerik:RadTextBox ID="txtFeedbackName" Width="120px" runat="server"></telerik:RadTextBox>
                            </div>
                            <div>
                                <label>备注：</label>
                                <telerik:RadTextBox ID="txtRemark" Width="120px" runat="server"></telerik:RadTextBox>
                            </div>
                            <div>
                                <telerik:RadButton runat="server" ID="btnSearch" OnClick="btnSearch_Click" Text="搜索"></telerik:RadButton>
                            </div>

                            <div style="float: right;">
                                <telerik:RadButton RenderMode="Lightweight" EnableSplitButton="true" ID="btnMoreAction" AutoPostBack="false"
                                    runat="server" Text="操作" OnClientClicked="CurrentPage.OnClientClicked" OnClientLoad="CurrentPage.btnMoreActionOnClientLoad">
                                </telerik:RadButton>
                                <telerik:RadContextMenu ID="radContextMenuMoreAction" runat="server" OnClientItemClicked="CurrentPage.OnClientItemClicked" OnClientLoad="CurrentPage.radContextMenuMoreActionOnClientLoad">
                                    <Items>
                                        <%-- <telerik:RadMenuItem Text="编辑选中项" Value="Edit" ImageUrl="/Assets/WebformAssets/Images/MenuIcon/Decline.png">
                                        </telerik:RadMenuItem>--%>
                                        <telerik:RadMenuItem Text="删除选中项" Value="Delete" ImageUrl="/Assets/WebformAssets/Images/MenuIcon/Decline.png">
                                        </telerik:RadMenuItem>
                                        <telerik:RadMenuItem Text="标记为忽略" Value="Ignore" ImageUrl="/Assets/WebformAssets/Images/MenuIcon/wrench.png">
                                        </telerik:RadMenuItem>
                                    </Items>
                                </telerik:RadContextMenu>
                                <asp:Button ID="btnMoreActionRun" runat="server" CssClass="hidden" OnClick="btnMoreActionRun_Click" />
                                <asp:HiddenField ID="btnMoreActionRunCommandName" runat="server" Value="" />
                            </div>
                        </div>

                    </ContentTemplate>
                </telerik:RadDock>
            </telerik:RadDockZone>
        </telerik:RadDockLayout>
        <div style="height: 10px;"></div>
    </asp:Panel>


    <telerik:RadGrid ID="rgFeedbacks" runat="server" GridLines="None" AllowPaging="True" AllowCustomPaging="True"
        AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="True" AllowFilteringByColumn="False"
        OnNeedDataSource="rgFeedbacks_NeedDataSource" OnUpdateCommand="rgFeedbacks_UpdateCommand"
        OnItemCreated="rgFeedbacks_ItemCreated"
        OnItemCommand="rgFeedbacks_ItemCommand"
        OnInsertCommand="rgFeedbacks_InsertCommand" OnDeleteCommand="rgFeedbacks_DeleteCommand"
        OnPageIndexChanged="rgFeedbacks_PageIndexChanged" OnPageSizeChanged="rgFeedbacks_PageSizeChanged"
        ShowFooter="False" ShowHeader="true" GroupingSettings-CaseSensitive="false" AllowMultiRowSelection="false">
        <ClientSettings EnableRowHoverStyle="true">
            <Selecting AllowRowSelect="True"></Selecting>
            <ClientEvents OnCommand="rgFeedbacksOnCommand" />

        </ClientSettings>


        <MasterTableView Font-Size="12px" Width="100%" CommandItemDisplay="Top" ItemStyle-HorizontalAlign="Left"
            PagerStyle-AlwaysVisible="true" AlternatingItemStyle-HorizontalAlign="Left"
            PagerStyle-Feedback="Bottom" ClientDataKeyNames="FeedbackID"
            DataKeyNames="FeedbackID"
            PageSize="10">
            <Columns>
                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
                    <HeaderStyle Width="26px" />
                </telerik:GridClientSelectColumn>

                <telerik:GridBoundColumn UniqueName="FacilityCode" HeaderText="设备编号" DataField="FacilityCode">
                    <ItemStyle Width="100" />
                    <HeaderStyle Width="100" />
                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn UniqueName="OrganizationName" HeaderText="机构" DataField="OrganizationName">
                    <ItemStyle Width="120" />
                    <HeaderStyle Width="120" />
                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn UniqueName="FacilityIssueTypeName" HeaderText="类型" DataField="FacilityIssueTypeName">
                    <ItemStyle Width="100" />
                    <HeaderStyle Width="100" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="FeedbackStatusName" HeaderText="状态" DataField="FeedbackStatusName">
                    <ItemStyle Width="100" />
                    <HeaderStyle Width="100" />
                </telerik:GridBoundColumn>


                <telerik:GridBoundColumn UniqueName="Description" HeaderText="问题描述" DataField="Description">
                    <ItemStyle Width="200" />
                    <HeaderStyle Width="200" />
                </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn UniqueName="FeedbackResult" HeaderText="处理结果" DataField="FeedbackResult">
                    <ItemStyle Width="100" />
                    <HeaderStyle Width="100" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="CreateAt" HeaderText="提交时间" DataField="CreateAt" DataFormatString="{0:yyyy-MM-dd HH:mm}">
                    <ItemStyle Width="80" />
                    <HeaderStyle Width="80" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="Remark" HeaderText="备注" DataField="Remark">
                </telerik:GridBoundColumn>

                <telerik:GridTemplateColumn HeaderText="操作" UniqueName="txtColDescription" ItemStyle-Width="50" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left">
                    <ItemTemplate>
                        <a class="gridActionButton" onclick="rgFeedbacksOnEditCommand('<%#Eval("FeedbackID").ToString() %>');">编辑</a>
                        <%--                        <a class="gridActionButton" onclick="rgFeedbackGroupsOnDeleteCommand(this,'<%#Eval("FeedbackGroupID").ToString() %>');">删除</a>
                        <asp:Button ID="lbtnDeleteHiden" CssClass="hidden" runat="server" CommandName="Delete" />--%>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            var FeedbackEditPageUrl = '<%=ResolveClientUrl("/Admin/FacilityManage/FeedbackEdit.aspx?FeedbackID=") %>';
            var rgFeedbacks = null;
            $(document).ready(function () {
                rgFeedbacks = $find('<%=rgFeedbacks.ClientID %>');
                CurrentPage.init();
            });


            function rgFeedbacksOnCommand(sender, eventArgs) {
                //retrieve the current commandName and commandArgument
                var commandName = eventArgs.get_commandName();
                if (commandName == "InitInsert") {
                    rgFeedbacksOnInsertCommand(eventArgs);
                }
                else if (commandName == "Edit") {

                }

                //eventArgs.set_cancel(true); //cancel the command
            }
            function rgFeedbacksOnInsertCommand(eventArgs) {
                var addUrl = FeedbackEditPageUrl + "-1";
                DefaultWindow.openWindow('添加', addUrl, 800, 500);
                eventArgs.set_cancel(true);
            }
            function rgFeedbacksOnEditCommand(FeedbackID) {
                var editUrl = FeedbackEditPageUrl + FeedbackID;
                DefaultWindow.openWindow('编辑', editUrl, 800, 500);

            }
            function rgFeedbacksOnViewSecurityItemsCommand(FeedbackID) {
                var editUrl = SecurityItemsPageUrl + FeedbackID;
                location.href = editUrl;
            }
            //SecurityItems.aspx
            function rgFeedbacksOnDeleteCommand(self, FeedbackID) {
                onDeleteRadconfirm('确定要删除吗？', function (arg) {
                    if (arg) {
                        $(self).next().click();
                    }
                });
            }


            var CurrentPage = {};
            CurrentPage.init = function () {
                CurrentPage.btnMoreActionRun = $('#<%=btnMoreActionRun.ClientID %>');
                CurrentPage.btnMoreActionRunCommandNameClientID = '<%=btnMoreActionRunCommandName.ClientID %>';
            }
            CurrentPage.btnMoreActionRun = null;
            CurrentPage.btnMoreActionRunCommandNameClientID = null;
            CurrentPage.radContextMenuMoreAction = null;
            CurrentPage.btnMoreAction = null;
            CurrentPage.radContextMenuMoreActionOnClientLoad = function (sender, args) {
                CurrentPage.radContextMenuMoreAction = sender;
            }
            CurrentPage.btnMoreActionOnClientLoad = function (sender, args) {
                CurrentPage.btnMoreAction = sender;
            }
            CurrentPage.OnClientClicked = function (sender, args) {

                if (args.IsSplitButtonClick() || !sender.get_commandName()) {
                    var currentLocation = $telerik.getBounds(sender.get_element());
                    CurrentPage.radContextMenuMoreAction.showAt(currentLocation.x, currentLocation.y + currentLocation.height);
                }
            }

            CurrentPage.OnClientItemClicked = function (sender, args) {
                var itemValue = args.get_item().get_value();
                var itemText = args.get_item().get_text();
                if (CurrentPage.getSelectedRowCount() <= 0) {
                    showNotification("请选择要操作的项", "操作提示", 3000);
                    return false;
                }
                if (itemValue == "Edit") {
                    var curSelectedItem = CurrentPage.getSelectedItem();
                    var wpSecurityTableID = curSelectedItem.getDataKeyValue("WpSecurityTableID");
                    rgFeedbacksOnEditCommand(wpSecurityTableID);
                    return;
                }
                var btnMoreActionRunCommandName = $("#" + CurrentPage.btnMoreActionRunCommandNameClientID);
                btnMoreActionRunCommandName.val(itemValue);
                onDefaultRadconfirm('确定要' + itemText + '吗？', function (arg) {
                    if (arg) {
                        console.log("btnMoreActionRunCommandName=" + btnMoreActionRunCommandName.val());
                        CurrentPage.btnMoreActionRun.click();
                    }
                });
            }
            CurrentPage.RowDeselected = function (sender, eventArgs) {
                //your code
            }

            CurrentPage.RowSelected = function (sender, eventArgs) {
                var MasterTable = sender.get_masterTableView();
                var selectedRows = MasterTable.get_selectedItems();
                var selectedRowsCount = selectedRows.length;
                //etc
            }
            CurrentPage.getSelectedRowCount = function () {
                var masterTable = rgFeedbacks.get_masterTableView();
                var selectedRows = masterTable.get_selectedItems();
                var selectedRowsCount = selectedRows.length;
                return selectedRowsCount;
            }
            CurrentPage.getSelectedItem = function () {
                var masterTable = rgFeedbacks.get_masterTableView();
                var selectedRows = masterTable.get_selectedItems();
                if (selectedRows.length > 0) {
                    return selectedRows[0];
                }
                return null;
            }

            function refreshPageWithState() {
                var grid = rgFeedbacks.get_masterTableView();
                grid.rebind();
            }

        </script>

    </telerik:RadCodeBlock>
</asp:Content>


